<template>
	<view class="flex flex-col">
		<view class="" v-if="!isCard">
			<text class="text-sm font-bold">支付类型</text>
			<view class="flex items-center pt-20 pb-20">
				<radioCompVue v-model="postFrom.paysts" :item="item" v-for="(item, idx) in payList" :key="idx"></radioCompVue>
			</view>
		</view>
		<view class="mb-20" v-if="!isCard">
			<text class="text-sm font-bold">您希望打赏咨询师多少钻？</text>
			<view class="flex items-center pt-20 pb-20 flex-wrap">
				<template v-if="postFrom.paysts == 0">
					<radioCompVue v-model="postFrom.sinpay" :item="item" :type="postFrom.paysts"
						v-for="(item, idx) in blueDiamondList" :key="idx" @click="handleCustom(false)"></radioCompVue>
				</template>
				<template v-else>
					<radioCompVue v-model="postFrom.sinpay" :item="item" :type="postFrom.paysts"
						v-for="(item, idx) in redDiamondList" :key="idx" @click="handleCustom(false)"></radioCompVue>
				</template>
				<view class="flex items-center box-custom mt-20" @click="handleCustom(true)">
					<ImageBoxVue class="mr-10" :src="postFrom.paysts==0?'/static/icons/blue.png':'/static/icons/red.png'"
						width="28rpx" height="28rpx">
					</ImageBoxVue>
					<uni-easyinput class="mr-10" v-model="postFrom.sinpay" type="number" placeholder="请输入金额"></uni-easyinput>
					<text class="mr-10">颗</text>
					<ImageBoxVue v-if="isCustom" src="/static/icons/selected.png" width="36rpx" height="36rpx"></ImageBoxVue>
					<ImageBoxVue v-else src="/static/icons/no_selected.png" width="36rpx" height="36rpx">
					</ImageBoxVue>
				</view>
			</view>
			<text class="text-[#329EFF]">打赏的蓝钻数量越多，你的帖子就会越靠前，也会优先推荐给资深咨询师打赏的蓝钻数量越多，你的帖子就会越靠前，也会优先推荐给资深咨询师</text>
		</view>
	<!-- 	<view class="flex flex-col">
			<text class="text-sm font-bold">您希望多少位咨询师为您解读？</text>
			<view class="flex items-center pt-20 pb-20">
				<radioCompVue v-model="postFrom.pret" :item="item" v-for="(item, idx) in pretList" :key="idx"></radioCompVue>
			</view>
		</view> -->
	<!-- 	<view class="mb-20" v-if="postFrom.paysts==0">
			<view class="flex flex-col">
				<view class="flex items-center">
					<text class="text-sm font-bold">是否保密</text>
					<text>12颗</text>
					<ImageBoxVue src="/static/icons/blue.png" width="28rpx" height="28rpx"></ImageBoxVue>
					<text class="text-sm font-bold">让本帖成为保密贴?</text>
				</view>
				<view class="flex items-center pt-20 pb-20">
					<radioCompVue v-model="postFrom.sec" :item="item" v-for="(item, idx) in confirm" :key="idx"></radioCompVue>
				</view>
			</view>
			<text class="text-[#329EFF] mt-20">保密贴不会展示任何你的个人信息支队咨询师展示问题本身对咨询师之外的任何人都不展示</text>
		</view> -->
	<!-- 	<view class="flex flex-col">
			<text class="text-sm font-bold">您是否允许游客参与解读？</text>
			<view class="flex items-center pt-20 pb-20">
				<radioCompVue v-model="postFrom.exp" :item="item" v-for="(item, idx) in confirm" :key="idx"></radioCompVue>
			</view>
		</view>
		<view class="flex flex-col">
			<text class="text-sm font-bold">您是否允许游客参与讨论？</text>
			<view class="flex items-center pt-20 pb-20">
				<radioCompVue v-model="postFrom.obs" :item="item" v-for="(item, idx) in confirm" :key="idx"></radioCompVue>
			</view>
		</view> -->
		<view class="" v-if="isView">
			<view class="rounded-lg bg-white p-20">
				<postCompVue :post="postFrom" :type="1"></postCompVue>
				<view class="line mt-20"></view>
				<view v-if="aanlist">
					<unscrambleCompVue v-for="(item, idx) in aanlist" :key="idx" :post="item" :userType="1" :type="1"
						:obs="postFrom.obs"></unscrambleCompVue>
				</view>
				<view v-if="manlist">
					<unscrambleCompVue v-for="(item, idx) in manlist" :key="idx" :post="item" :userType="2" :type="1"
						:obs="postFrom.obs"></unscrambleCompVue>
				</view>
			</view>
		</view>
	</view>
</template>

<script setup>
	import {
		ref,
		inject,
		watch,
		computed,
		onMounted,
	} from 'vue';
	import radioCompVue from './radioComp.vue';
	import postCompVue from '@/components/postComp.vue';
	import unscrambleCompVue from '@/components/unscrambleComp.vue';
	const pretList = inject('pretList')
	const systemSetting = inject('systemSetting')
	const postFrom = inject('postFrom')
	const posts = inject('posts')

	defineProps({
		isCard: {
			type: Boolean,
			default: false
		},
		isView: {
			type: Boolean,
			default: true
		}
	})

	const blueDiamondList = ref([]) // 蓝钻价格列表
	const redDiamondList = ref([]) // 红钻价格列表
	const isCustom = ref(false) // 是否自定义
	const member = ref({}) // 模拟帖子数据
	const aanlist = ref([]) // 模拟帖子数据
	const manlist = ref([]) // 模拟帖子数据

	const payList = [{
		text: "蓝钻",
		value: 0
	}, {
		text: "红钻",
		value: 1
	}]
	const confirm = [{
		text: "否",
		value: 0
	}, {
		text: "是",
		value: 1
	}]

	watch(() => {
		return postFrom.value.paysts
	}, () => {
		postFrom.value.sinpay = ''
		// console.log(minCount.value)
	})
	watch(() => {
		return postFrom.value.pret
	}, () => {
		aanlist.value = new Array(postFrom.value.pret).fill({
			"id": "1362453232533635072",
			"isedit": 0,
			"sort": 0,
			"del": 0,
			"page": 1,
			"limit": 10,
			"count": 0,
			"startnum": 0,
			"pagecount": 0,
			"openPage": 0,
			"addtime": "2025-04-17T07:42:44.000+00:00",
			"editime": null,
			"deltime": null,
			"remark": null,
			"token": null,
			"tou": 0,
			"anchor": {
				"id": "1357710088109817856",
				"isedit": 0,
				"sort": 0,
				"del": 0,
				"page": 1,
				"limit": 10,
				"count": 0,
				"startnum": 0,
				"pagecount": 0,
				"openPage": 0,
				"addtime": null,
				"editime": null,
				"deltime": null,
				"remark": null,
				"token": null,
				"member": null,
				"achorlevel": null,
				"liveback": null,
				"name": "小张",
				"nickname": "133****4136",
				"bluedia": null,
				"reddia": null,
				"voiblue": null,
				"privoiblue": null,
				"voired": null,
				"privoired": null,
				"todayblue": null,
				"todayred": null,
				"freeze": null,
				"headimg": "",
				"phone": null,
				"idcard": null,
				"idcardfront": null,
				"idcardback": null,
				"acadimg": null,
				"troduction": null,
				"viomsg": null,
				"adlive": 0,
				"adpmic": 0,
				"adcom": 0,
				"adcou": 0,
				"spexp": 0,
				"examine": 0,
				"rec": 0,
				"stsmic": 0,
				"slb": 0,
				"rdb": 0,
				"wdb": 0,
				"exp": 0,
				"job": 1,
				"durtime": 0,
				"folw": 0,
				"fas": 0
			},
			"member": null,
			"sts": 0,
			"details": "下个月主要关注一下情绪方面的问题，很容易因为自身情绪问题误导致跟另外一半发生争吵，另外要注意与其他异性的距离。下个月财运不错，建议把主要精力放在工作及赚钱方面。",
			"ado": 1,
			"headimg": "",
			"eval": 0,
			"buy": 0,
			"pins": 100,
			"zd": 0,
			"yc": 0
		})
	})
	watch(() => {
		return postFrom.value.exp
	}, () => {
		manlist.value = new Array(2).fill({
			"id": "1362453232533635072",
			"isedit": 0,
			"sort": 0,
			"del": 0,
			"page": 1,
			"limit": 10,
			"count": 0,
			"startnum": 0,
			"pagecount": 0,
			"openPage": 0,
			"addtime": "2025-04-17T07:42:44.000+00:00",
			"editime": null,
			"deltime": null,
			"remark": null,
			"token": null,
			"tou": 0,
			"member": {
				"id": "1357710088109817856",
				"isedit": 0,
				"sort": 0,
				"del": 0,
				"page": 1,
				"limit": 10,
				"count": 0,
				"startnum": 0,
				"pagecount": 0,
				"openPage": 0,
				"addtime": null,
				"editime": null,
				"deltime": null,
				"remark": null,
				"token": null,
				"member": null,
				"achorlevel": null,
				"liveback": null,
				"name": "小张",
				"nickname": "小张",
				"openlev": 3,
				"bluedia": null,
				"reddia": null,
				"voiblue": null,
				"privoiblue": null,
				"voired": null,
				"privoired": null,
				"todayblue": null,
				"todayred": null,
				"freeze": null,
				"headimg": "",
				"phone": null,
				"idcard": null,
				"idcardfront": null,
				"idcardback": null,
				"acadimg": null,
				"troduction": null,
				"viomsg": null,
				"adlive": 0,
				"adpmic": 0,
				"adcom": 0,
				"adcou": 0,
				"spexp": 0,
				"examine": 0,
				"rec": 0,
				"stsmic": 0,
				"slb": 0,
				"rdb": 0,
				"wdb": 0,
				"exp": 0,
				"job": 1,
				"durtime": 0,
				"folw": 0,
				"fas": 0
			},
			"sts": 0,
			"details": "下个月主要关注一下情绪方面的问题，很容易因为自身情绪问题误导致跟另外一半发生争吵，另外要注意与其他异性的距离。下个月财运不错，建议把主要精力放在工作及赚钱方面。",
			"ado": 1,
			"headimg": "",
			"eval": 0,
			"buy": 0,
			"pins": 100,
			"zd": 0,
			"yc": 0
		})
	})

	const minCount = computed(() => {
		let count = 0
		if (postFrom.value.paysts == 0) {
			blueDiamondList.value.map((item, idx) => {
				if (idx == blueDiamondList.value.length - 1) {
					count = item.num
				}
			})
		} else {
			redDiamondList.value.map((item, idx) => {
				if (idx == redDiamondList.value.length - 1) {
					count = item.num
				}
			})
		}
		return count
	})
	postFrom.value.posts = posts.value
	postFrom.value.member = {
		"id": "1323713529643008000",
		"isedit": 0,
		"sort": 0,
		"del": 0,
		"page": 1,
		"limit": 10,
		"count": 0,
		"startnum": 0,
		"pagecount": 0,
		"openPage": 0,
		"addtime": "2024-12-31T10:04:59.000+00:00",
		"editime": null,
		"deltime": null,
		"remark": null,
		"token": null,
		"phone": "15882779082",
		"headimg": "",
		"nickname": "小张",
		"name": null,
		"code": null,
		"bluedia": 49765,
		"reddia": 2420,
		"dayspend": null,
		"freeze": null,
		"openlev": 3,
		"memberlevel": null,
		"exp": 0,
		"cl": 0,
		"gender": 0,
		"sig": null,
		"birday": null,
		"ach": 0,
		"popnum": 0,
		"bepopnum": 0,
		"possnum": 0,
		"plnum": 0,
		"starsign": null,
		"birday_str": null,
		"tblue": null,
		"tred": null,
		"anchor": null
	}

	const getBlueList = () => {
		let arr = [];
		systemSetting.value.map(item => {
			if (item.name == 'PsychologicalBlueFees') {
				const obj = {
					needIcon: true,
					num: item.kbidc
				}
				const obj2 = {
					needIcon: true,
					num: item.kbidc * 2
				}
				const obj3 = {
					needIcon: true,
					num: item.kbidc * 3
				}
				arr.push(obj)
				arr.push(obj2)
				arr.push(obj3)
			}
		})
		blueDiamondList.value = arr
	}
	const getRedList = () => {
		let arr = [];
		systemSetting.value.map(item => {
			if (item.name == 'PsychologicalRedFees') {
				const obj = {
					needIcon: true,
					num: item.kbidc
				}
				const obj2 = {
					needIcon: true,
					num: item.kbidc * 2
				}
				const obj3 = {
					needIcon: true,
					num: item.kbidc * 3
				}
				arr.push(obj)
				arr.push(obj2)
				arr.push(obj3)
			}
		})
		redDiamondList.value = arr
	}
	getBlueList();
	getRedList();
	const handleCustom = (flag) => {
		if (flag) {
			isCustom.value = true
			postFrom.value.sinpay = ''
		} else {
			isCustom.value = false
		}
	}
</script>

<style lang="scss" scoped>
	.box-custom {
		:deep(.uni-easyinput__content) {
			width: 180rpx;
		}
	}
</style>